﻿/*************************************************
作者: Plane
邮箱: 1785275942@qq.com
功能: 定时服务

           ~~获取更多教学资讯~~
//----------------*----------------\\
        教学官网：www.qiqiker.com
        官方微信服务号: qiqikertuts
        Plane老师微信: PlaneZhong
\\----------------*----------------//
*************************************************/

using System;
using PETimer;

public class TimerSvc : ILogic {
    readonly TickTimer timer = new(0, false);

    //-------------Flow Functions-------------//
    public void Init() {
        timer.LogFunc = this.Log;
        timer.WarnFunc = this.Warn;
        timer.ErrorFunc = this.Error;

        this.Log("Init TimerSvc Done.");
    }
    public void Tick() {
        timer.UpdateTask();
    }
    public void UnInit() {
        this.Log("UnInit TimerSvc.");
    }

    //-------------Tool Functions-------------//
    public int AddTask(uint delay, Action<int> taskCB, Action<int> cancelCB = null, int count = 1) {
        return timer.AddTask(delay, taskCB, cancelCB, count);
    }
    public bool DeleteTask(int tid) {
        return timer.DeleteTask(tid);
    }
}